﻿using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;

namespace LightSwitchApplication
{
    public partial class SalesPersonDetail
    {
        partial void SalesPerson_Loaded(bool succeeded)
        {
            // Write your code here.
            this.SetDisplayNameFromEntity(this.SalesPerson);
        }

        partial void SalesPerson_Changed()
        {
            // Write your code here.
            this.SetDisplayNameFromEntity(this.SalesPerson);
        }

        partial void SalesPersonDetail_Saved()
        {
            // Write your code here.
            this.SetDisplayNameFromEntity(this.SalesPerson);
        }

        partial void SalesPersonAddressesAddAndEditNew_CanExecute(ref bool result)
        {
            // Write your code here.

        }

        partial void SalesPersonAddressesAddAndEditNew_Execute()
        {
            this.Application.ShowCreateNewAddress(0, 0, 0, this.SalesPerson.Id);
        }

        partial void SalesPersonAddressesEditSelected_CanExecute(ref bool result)
        {
            // Write your code here.

        }

        partial void SalesPersonAddressesEditSelected_Execute()
        {
            if (this.SalesPersonAddresses.SelectedItem != null)
                this.Application.ShowAddressDetail(this.SalesPersonAddresses.SelectedItem.Id);
        }

        partial void SalesPersonDetail_Activated()
        {
            this.DisplayName = this.SalesPerson.SalesPersonName.ToString() + " (Торговый представитель)";
            try
            {
                this.FindControl("Save").IsEnabled = this.Application.User.HasPermission(Permissions.CanEditSalesPerson);
                this.FindControl("aspnet_Profile").IsEnabled = this.Application.User.HasPermission(Permissions.CanEditSalesPerson);
            }
            catch (Exception)
            {
            }
        }

        partial void SalesPersonDetail_InitializeDataWorkspace(List<IDataService> saveChangesTo)
        {
        }

        partial void ContactsAddAndEditNew_CanExecute(ref bool result)
        {
            // Write your code here.

        }

        partial void ContactsAddAndEditNew_Execute()
        {
            this.Application.ShowCreateNewContact(0, 0, this.SalesPerson.Id);
        }
    }
}